package main

import "fmt"

type Person11 struct {
	Name string
	Sex  byte
	Age  int
}

type Student11 struct {
	Person11
	Class string
}

type Student12 struct {
	person Person11
	Class  string
}

type Student13 struct {
	person  Person11
	person1 Person11
	Class   string
	person2 Person11
}

func main() {
	stu := Student11{Person11: Person11{
		Name: "测试1",
		Sex:  0,
		Age:  0,
	},
		Class: "",
	}

	fmt.Println(stu)
	//fmt.Println(stu.Person11) 这样也可以访问  默认名就是其本身

	stu2 := Student12{
		person: Person11{},
		Class:  "",
	}
	fmt.Println(stu2)

	stu3 := Student13{
		person:  Person11{},
		person1: Person11{},
		Class:   "",
		person2: Person11{},
	}

	stu4 := Student13{Person11{}, Person11{}, "", Person11{}}
	//stu5 := Student13{Person11{},"",Person11{},Person11{}}
	// 必须按照顺序设置字段，否则报错
	fmt.Println(stu3)
	fmt.Println(stu4)
	//fmt.Println(stu5)
}
